package com.zhangpp.controller;

import com.zhangpp.dto.PageDTO;
import com.zhangpp.entity.User;
import com.zhangpp.service.UserService;
import com.zhangpp.vo.CommonQueryPageVO;
import com.zhangpp.vo.CommonVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@RequestMapping("user")
//queryAllPage   delete   update  PageDTO  CommonVO
//CommonQueryPageVO
public class UserController {
    private static final Logger log = LoggerFactory.getLogger(UserController.class);
    @Resource
    UserService userService;
    @RequestMapping("queryAllPage")
    public CommonQueryPageVO queryAllPage(@RequestBody PageDTO pageDTO) {
        log.info("当前页：{}", pageDTO.getPage());

        CommonQueryPageVO commonQueryPageVO = userService.queryAllPages(pageDTO.getPage(), pageDTO.getPageSize());

        return commonQueryPageVO;
    }

    @RequestMapping("update")
    public CommonVO update(@RequestBody User user){
        log.info("------------{}",user);
        return userService.updates(user);
    }
}

